package cn.com.oceansoft.nos.taglib;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;


/**
 * Select 解析标签
 * Created by xujin on 2014/9/5.
 */
public class SelectValueTag extends TagSupport {
    private int code;
    private int value;

    private final static int MEMBER_STATUS_CODE = 1000;   //用户审核状态
    private final static int MESSAGE_CODE = 2000;   //消息列表 - 推送对象

    public int doStartTag() throws JspException {
        return super.SKIP_BODY;
    }

    public int doEndTag() throws JspException {
        JspWriter out = pageContext.getOut();
        try {
            switch (this.code) {
                case MEMBER_STATUS_CODE:
                    out.print(getMemberStatusStr(this.value));
                case MESSAGE_CODE:
                    out.print(getMsgTypeStr(this.value));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return super.SKIP_BODY;
    }

    public String getMemberStatusStr(int value) {
        switch (value) {
            case 0:
                return "锁定";
            case 1:
                return "正常";
            case 2:
                return "禁用";
        }
        return "无此状态值";
    }

    public String getMsgTypeStr(int value) {
        switch (value) {
            case 4:
                return "广播";
            case 2:
                return "群组";
            case 3:
                return "单发";
        }
        return "";
    }

    public void release() {
        super.release();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }
}
